﻿using ALMDDD.Domain.Core.Models;
using ALMDDD.Domain.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Text;

namespace ALMDDD.Infrastructure.Mappings
{
    /// <summary>
    /// 用户实体属性配置
    /// </summary>
    public class SysUserMap : IEntityTypeConfiguration<Sys_User>
    {
        public void Configure(EntityTypeBuilder<Sys_User> builder)
        {
           
            builder.ToTable("sys_user");//表名
            builder.HasIndex(p => p.TrxTime);//非聚集非唯一索引

            builder.HasKey(c=>c.Id);//主键
            builder.Property(c => c.Id)
                 .HasColumnName("Id");
            builder.Property(c => c.Email)
                .HasColumnType("varchar(40)")
                .HasMaxLength(40);
            builder.Property(c => c.Gender)
                .HasColumnType("char(1)")
                .IsRequired();
            builder.Property(c => c.PassWord)
                .HasColumnType("varchar(30)")
                .IsRequired();
            builder.Property(c => c.Phone)
                .HasMaxLength(15)
                .HasColumnType("varchar(15)");
            builder.Property(c => c.TrxTime)
                .HasColumnType("dateTime");
            builder.Property(c => c.UserId)
                .HasColumnType("varchar(30)")
                .IsRequired();
            //生成操作人姓名
            builder.Property(c => c.TrxName)
                 .HasColumnName("trxName")
                 .HasColumnType("varchar(20)");
            //操作时间
            builder.Property(c => c.TrxTime)
                .HasColumnName("trxTime")
                .HasColumnType("datetime");
            //操作人
            builder.Property(c => c.TrxUser)
                .HasColumnName("trxUser")
                .HasColumnType("varchar(20)");


        }
    }
}
